home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_iijsfuncs.inc < prev    next >
Encoding:
Text File  |  1999-07-09  |  3.3 KB  |  127 lines

  1. <% ' General depository for frequently used javascript functions ******* %>
  2.  
  3.  
  4. <% ' ******* Any localizable strings needed for these functions will appear in iijsfuncs.str ******* %>
  5. <!--#include file="iijsfuncs.str"-->
  6.  
  7. <% ' ******* Pops open a new dialog of specified height, with or without an ok/cancel/help toolbar ******* %>
  8. <% ' ******* hideTools is optional ******* %>
  9.  
  10.     function popBox(title, width, height, filename, hideTools){
  11.         thefile=(filename + ".asp");
  12.         thefile="iipop.asp?pg="+thefile;
  13.         if (hideTools)
  14.         {
  15.             thefile += "&tools=no";
  16.         }            
  17.         
  18.  
  19.         //Store the window object in our Global variables, so it may be refered to from the parent window...
  20.         top.title.Global.popwindow=window.open(thefile,title,"toolbar=no,scrollbars=yes,directories=no,menubar=no,width="+width+",height="+height);
  21.  
  22.         //pop it into a local var for reference here...
  23.         popbox = top.title.Global.popwindow;
  24.  
  25.         //corrects for bug in ie where the window opener property wasn't being set.
  26.         if(popbox !=null){
  27.             if (popbox.opener==null){
  28.                 popbox.opener=self;
  29.             }
  30.         }
  31.  
  32.         //corrects for a bug where if the window is opened, and then re-opened, it stays in the back.
  33.         //however, this errors in IE3, so we are special casing it. IE3 will have the less desirable
  34.         //behavior of remaining in the background.
  35.  
  36.         <% if Session("isIE") and Session("browserver") < 4 then %>
  37.             <% ' no focus... browser doesn't suppor it %>
  38.         <% else %>        
  39.             popbox.focus();
  40.         <% end if %>
  41.         
  42.     }
  43.  
  44. <% ' ******* Basic Crop function based on string length ******* %>
  45.  
  46.     function crop(thestring,size){
  47.         sLen = thestring.length
  48.         if (sLen > size)
  49.             {
  50.             thestring = thestring.substring(0,size) + "...";
  51.             }
  52.         else{
  53.             for (var i = sLen ; i < size; i++) {
  54.                 thestring = thestring + " "
  55.             }            
  56.         }
  57.         return thestring;
  58.     }
  59.  
  60. <% ' ******* Quick function to provide alternate text if there is no value to the main display string. ******* %>
  61.     function displayVal(dispstr, altstr){
  62.         if (dispstr == ""){
  63.             dispstr = altstr;
  64.         }
  65.         return dispstr;
  66.     }
  67.  
  68.     
  69. <% ' ******* Basic Numeric checker that displays a dialog. Strings are located in iijsfunc.str ******* %>
  70.     
  71.     function isNum(txtcntrl,min,max) {
  72.         str=txtcntrl.value;
  73.         
  74.         minval = min-1;
  75.         maxval = max+1;
  76.     
  77.         for (var i=0; i < str.length; i++) {
  78.               num = parseInt(str.substring(i,i+1));
  79.             if (isNaN(num)){                
  80.                alert("<%= L_ENTERINT %>");
  81.                 txtcntrl.value = txtcntrl.defaultValue;
  82.                 return false;
  83.               }            
  84.          }
  85.         num = str;
  86.         
  87.         if (min != ""){    
  88.             if (num < min) {
  89.                 alert('<%= L_GREATERTHAN %>');
  90.                 txtcntrl.value = txtcntrl.defaultValue;
  91.                 return false;
  92.             }
  93.         }
  94.         
  95.         if (max != ""){
  96.             if (num > max) {
  97.                 alert('<%= L_LESSTHAN %>');
  98.                 txtcntrl.value = txtcntrl.defaultValue;
  99.                 return false;
  100.             }        
  101.         }
  102.         return true;
  103.     }
  104.     
  105. <% ' ******* Disables controls if the browser is DHTML compatible ******* %>
  106.     function setCntrlState(mState,mControl){
  107.         <% if Session("hasDHTML") then %>
  108.             mControl.disabled = ! mState;
  109.         <% end if %>
  110.     }
  111.     
  112.  
  113. <% ' ******* Search for a string in a string  ******* %>
  114. <% ' ******* I just don't like jscripts substring method... **** %>
  115.     function bAnyInStr(sToSearch, sToFind)
  116.     {
  117.         for (i=0;i < sToFind.length;i++)
  118.         {
  119.             if (sToSearch.indexOf(sToFind.substring(i,i+1)) > -1)
  120.             {
  121.                 return true;
  122.             }
  123.         }
  124.         return false;
  125.     }
  126.     
  127.